package validation;

import java.util.Hashtable;

import utility.Input;
import database.RecordSearch;
import dbmanager.DBManager;
import dbmanager.GetIdName;

public class Istype  implements Validation 
{
	DBManager db;
	String actualvalue;
	String validationvalue;
	GetIdName gid;
	String value;
	
	public String getMessage() 
	{
		return "Value must be of type "+validationvalue;
	}
	

	public void setDbmanager(DBManager db)
	{
		this.db=db;	
		gid= new GetIdName(db);
	}

	public boolean validate(String Value) 
	{	
		return false;
	}
	
	public boolean validate(String actualvalue, String validationvalue)
	{
		try
		{
			/*getProperty getproperty = new getProperty(db);
			String id= gid.getId(actualvalue);
			String validationid= gid.getId(validationvalue);
			 TYPE= gid.getId(TYPE);
			getproperty.setMid(id);
			getproperty.setPid(validationid);			
			String type = getproperty.getValue();*/
			String id= gid.getId(actualvalue);
			String validationid= gid.getId(validationvalue);
			//String MASTERPATH = Input.MASTERREPORTSPATH + validationid + "//" +validationid  + "_pv"+ Input.FILRFORMAT;
			/*file.SearchRecord sr = new file.SearchRecord(MASTERPATH);
			sr.fileOpen();*/
			Hashtable<Object, Object> temp =new Hashtable<Object, Object>();
			temp.put("mid", id);
			temp.put("pv", validationid);
			temp.put("td","null");
			RecordSearch ps = new RecordSearch(db);
			ps.setConditionMap(temp);
			String line[] = ps.getArrayFromResultSet();
			/*String line[] = sr.getRecordSet(temp);
			sr.fileClose();*/
			if(line.length==0)
				return false;
			else
				return true;
			/*
			if(type.toLowerCase().equals(validationvalue.toLowerCase()))
				return false;
			else
				return true;*/
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			return true;
		}
	}

	public boolean validate(String Value, String ConditionValue, String Refvalue) 
	{
		this.actualvalue = Value;
		this.validationvalue = ConditionValue;
		return validate(Value, ConditionValue);
	}

	public void setBasicvalue(String value) 
	{
		this.value = value;	
	}
}
